package utils;

import android.util.Log;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

public class OkHttpCallback implements Callback {
    private final String TAG = OkHttpCallback.class.getSimpleName();

    public String result;

    @Override
    public void onFailure(@NotNull Call call, @NotNull IOException e) {
        Log.d("test", "请求失败："+e.toString());
        onFinish("Failure",e.toString());
    }

    @Override
    public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
        result = response.body().string().toString();
        onFinish("Success",result);
    }

    public void onFinish(String status,String responseData){
        Log.d("test", status+":"+responseData);
    }
}
